package com.zide.auth.domain.entity.platform;

import cn.hutool.core.util.ObjectUtil;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableName;
import com.zide.common.core.domain.BaseEntity;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;

import java.time.LocalDate;
import java.util.List;

/**
 * @author 石添
 * @date 2024/8/24
 */
@Data
@TableName("platform_user")
@Schema(description = "平台用户表")
public class PlatformUser extends BaseEntity {

    @Schema(description = "用户名")
    private String username;
    private Long deptId;
    @Schema(description = "用户名")
    private String avatar;
    @Schema(description = "用户名")
    private String nickname;
    @Schema(description = "用户名")
    private String mobile;
    @Schema(description = "用户名")
    private String password;
    @Schema(description = "用户名")
    private Integer sex;
    @Schema(description = "状态")
    private Integer status;
    @Schema(description = "生日")
    private LocalDate birth;
    @Schema(description = "简介")
    private String description;

    /**
     * 角色对象
     */
    @TableField(exist = false)
    private List<PlatformRole> roles;

    /**
     * 角色组
     */
    @TableField(exist = false)
    private Long[] roleIds;

    /**
     * 岗位组
     */
    @TableField(exist = false)
    private Long[] postIds;

    /**
     * 角色ID
     */
    @TableField(exist = false)
    private Long roleId;

    public static boolean isAdmin(Long userId) {
        return ObjectUtil.isNotNull(userId) && userId == 1;
    }
    public boolean isAdmin() {
        return isAdmin(this.getId());
    }
}
